<template>
    <div>
        <el-form :model="ruleForm" ref="ruleForm" :label-position="labelPosition" label-width="150px" class="demo-ruleForm">
            <div class="container" style="margin-top:20px">
                <h3 style="margin-bottom: 20px">{{ruleForm.breedName}}</h3>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="物料类型：">
                            {{ruleForm.materialType}}
                        </el-form-item>
						<el-form-item label="产品大类：" v-if="keliShow || ruleForm.materialType == '中药饮片'">
							{{ruleForm.inventoryType}}
						</el-form-item>
                        <el-form-item label="物料代码：" >
                            {{ruleForm.materialCode}}
                        </el-form-item>
                        <div v-if="keliShow">
                             <el-form-item label="* 药品标识码标准：" >
                                {{ypCodeStandard}}
                            </el-form-item>
                            <el-form-item label="发药机编码：">
                                {{ruleForm.dispenserCode}}
                            </el-form-item>

                            <el-form-item label="规格：" prop="spec">
                                {{ruleForm.loadingQuantity}}g

                            </el-form-item>
                             <el-form-item label="规格对应饮片：" class="styleWidth">
                                {{ruleForm.ypQuantity}}g
                            </el-form-item>
                            <el-form-item label="上市备案号：">
                                {{ruleForm.prodRecordCode}}
                            </el-form-item>

                        </div>
                        <el-form-item label="规格：">
                            {{zypy?'细粉':ruleForm.loadingQuantity}}{{zypy?'':ruleForm.loadingUnits}}
                        </el-form-item>
                        <div v-if="ruleForm.materialType != '配方颗粒(浸膏粉)' && ruleForm.materialType != '配方颗粒'">
                            <el-form-item v-for="(item,index) in technologies"  :key="index" :label="'产地'+(index+1)+'：'">
                             {{item}}
                                <!-- <el-input v-model="item.specification" prop="specification" style="width:200px" placeholder="产地"></el-input>
                                <el-button @click = "deleteUnit(index)" class="delete_btn" style="margin-left:20px;">删除</el-button> -->
                            </el-form-item>
                        </div>
                        <!-- <el-form-item v-for="(item,index) in technologies"  :key="index" :label="'产地'+(index+1)+'：'">
                            {{item}}
                        </el-form-item> -->
                        <el-form-item  label='注意事项:' v-if='ruleForm.materialType == "中药饮片"'>
                            {{ruleForm.remark}}
                        </el-form-item>
                        <el-form-item  label='用法与用量:' v-if='ruleForm.materialType == "中药饮片"'>
                            {{ruleForm.usage}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="名称：">
                            {{ruleForm.breedName}}
                        </el-form-item>
                        <div v-if="keliShow">
                            <el-form-item label="存货代码：" >
                                {{ruleForm.inventoryCode}}
                            </el-form-item>
                            <el-form-item label="装量：">
                                {{ruleForm.pelletWeight}}{{ruleForm.loadingUnits}}
                            </el-form-item>
                        </div>
						<el-form-item label="保质期：">
						    {{ruleForm.deadLine}}月
						</el-form-item>
                        <div v-if="keliShow">
                            <el-form-item label="贮藏：">
                                {{ruleForm.storage}}
                            </el-form-item>
                        </div>
                        <div v-if="ssssshow">

                            <el-form-item label="规格码：">
                                <!-- <el-input placeholder="请输入内容" v-model.trim="ruleForm.specsCode" style="width: auto"></el-input> -->
                             {{ruleForm.specsCode}}
                            </el-form-item>
                            <el-form-item label="储存条件：" v-if='ruleForm.materialType == "中药饮片"'>
                                {{ruleForm.storage}}
                            </el-form-item>
                            <el-form-item label="装量：" v-if='ruleForm.materialType == "中药饮片"'>
                                {{ruleForm.pelletWeight}}{{ruleForm.loadingUnits}}
                            </el-form-item>
                            <el-form-item label="功能与主治：" v-if='ruleForm.materialType == "中药饮片"'>
                                {{ruleForm.effect}}
                            </el-form-item>
                        </div>
                    </el-col>
                  <el-col>
                      <el-form-item label="中药饮片执行标准：" v-if="ruleForm.materialType == '中药饮片'">
                          {{this.ruleForm.checkName}}
                      </el-form-item>
                      <el-form-item label="中药饮片执行标准：" v-if="ruleForm.materialType == '中药饮片(半成品)'">
                          {{this.ruleForm.checkName}}
                      </el-form-item>
                    <el-form-item label="提取饮片执行标准：" v-if="ruleForm.materialType == '提取饮片'">
                      {{this.ruleForm.checkName}}
                    </el-form-item>
                    <el-form-item label="中药配方颗粒执行标准：" v-if="ruleForm.materialType == '配方颗粒'">
                      {{this.ruleForm.checkName}}
                    </el-form-item>
                      <el-form-item label="存货代码：" v-if="ruleForm.materialType == '中药饮片'">
                          {{this.ruleForm.inventoryCode}}
                      </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item class="footerFixed">
                    <el-button @click="backPage">返回</el-button>
                </el-form-item>
            </div>
        </el-form>
    </div>
</template>

<script>
import {materialBreed_findById} from "@/request/api";
import uploadImg from '../../../common/uploadImg';
    export default {
        components: {
            uploadImg
        },
        data() {
            return {
                technologies:[],
                ssssshow:false,
                labelPosition:'right',
                showForm: false,
                keliShow: false,
                isDisabled: true,
                wlShow: false,
                ruleForm: {
                    breedName:'',
                    place: '',
                    materialType: '',
                    loadingQuantity: '',
                    loadingUnits: 'g',
                    spec: '',
                    specUnits: '',
                    dispenserCode: '',
                    inventoryCode: '',
                    ypQuantity: '',
                    ypUnits: 'g',
                },
                materialTypeStor: '',
                ypCodeStandard:''

            };
        },
        mounted(){
            this.id = this.$route.query.id
            if(this.id == undefined){

                }else{
                    this.init()
            }
            // if(this.$route.query.type == '辅料'){
            //     this.ssssshow = false
            // }else{
            //     this.ssssshow = true
            // }
        },
        methods: {
            backPage () {
                this.$router.go(-1);
                // this.ruleForm = {}
                this.$store.commit('setStorName',this.ruleForm.materialType)
            },
            //  查看状态
            init(){
                // 回显表单
                materialBreed_findById(this.id).then((res) => {
                    // technologies


                    this.ruleForm = res.data;
                     if(this.ruleForm.ypCodeStandard == 1){
                        this.ypCodeStandard = "国标"
                    }else if(this.ruleForm.ypCodeStandard == 2){
                        this.ypCodeStandard = "省标"
                    }
                    this.technologies = this.ruleForm.prodAddress.split(",")

                    if (res.data.materialType == '配方颗粒') {
                        this.keliShow = true
                        this.wlShow = false
                    }

                  // let data = "?type="+this.ruleForm.materialType  + "&standard=" + this.ruleForm.ypCodeStandard
                  // // 检测依据
                  // check_findByAll(data).then((res) =>{
                  //   this.checkList = res.data
                  // })

                    // else if(res.data.materialType == '提取饮片'){
                    //     this.wlShow = true
                    //     this.keliShow = false
                    // }
                    else{
                        this.keliShow = false
                        this.wlShow = false
                    }
                     if (res.data.materialType == '辅料') {
                        // this.keliShow = true
                        this.ssssshow = false
                        // this.wlShow = false
                    }else{
                        this.ssssshow = true
                    }
                    this.materialTypeStor = this.ruleForm.materialType
                })
            },
        }
    }
</script>
<style lang="less">
.styleWidth .el-input-group>.el-input__inner{ width: 200px !important;}
.styleWidth .el-select{ width: 60px !important;}
</style>
